package fan.project1_SpeedTalkSystem.ResponseAdvice;

import fan.project1_SpeedTalkSystem.Model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.resource.NoResourceFoundException;

@Slf4j
@ControllerAdvice
@ResponseBody
public class ExceptionHandler {
    @org.springframework.web.bind.annotation.ExceptionHandler
    public Result exceptionHandler(Exception e) {
        log.error("发生错误 e: ",e);
        return Result.fail("内部错误，请联系管理员","");
    }
    @org.springframework.web.bind.annotation.ExceptionHandler
    public Result exceptionHandle(NoResourceFoundException e) {
        log.info("找不到文件{}",e.getResourcePath());
        return Result.fail("没有这样的文件","");
    }
}
